<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../jq/jquery-1.11.3.js"></script>
    <script src="../jq/jquery-3.2.1.js"></script>
</head>
<body>
    <form id="input-form">
        <div>上传文件</div>
        <div><input name="file" id="input-file" type="file"></div>
        <div><input id="input-btn" type="button" value="上传"></div>
    </form>
    <div><a href="showFile.html">查看我上传的文件</a></div>
</body>
    <script>
        $("#input-btn").click(function () {
            var url = "../file/upload.do";
            var data = new FormData($("#input-form")[0]);
            console.log(data);
            $.ajax({
                "url" : url,
                "data" : data,
                "type" : "post",
                "dataType" : "json",
                "contentType": false,
                "processData": false,
                "success" : function (json) {
                    if(json.state == 200){
                        alert("上传成功");
                    }else{
                        alert(json.message);
                    }
                }
            })
        });
    </script>
</html>